#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QMessageBox>
#include<QPushButton>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    resize(800,600);
    QPushButton*btn=new QPushButton("消息对话框",this);
    QMessageBox*msg=new QMessageBox(this);
    msg->setWindowTitle("Warning Message");
    msg->setText("Error Message");
    //msg->setIcon(QMessageBox::Question);
    //msg->setIcon(QMessageBox::Information);
   // msg->setIcon(QMessageBox::Warning);
     msg->setIcon(QMessageBox::Critical);
    msg->setStandardButtons(QMessageBox::Open | QMessageBox::Close);
    connect(btn,&QPushButton::clicked,[=](){
        msg->show();
    });

}

MainWindow::~MainWindow()
{
    delete ui;
}

